// 引入创建路由的关键方法
import { createWebHistory, createRouter } from 'vue-router'
// 引入路由配置
import routes from '@/router/routes'
// 进度条
import Nprogress from 'nprogress'

// 创建路由
const router = createRouter({
  history: createWebHistory(),
  routes: routes
});

// 前置导航
router.beforeEach((to, form, next) => {
  Nprogress.start();
  if (to.meta.title) {
    document.title = to.meta.title as string;
  } else {
    document.title = "前端模板";
  }


  
  next()
});
// 后置导航
router.afterEach((to, form, next) => {
  Nprogress.done();
});







export default router;